package com.spring.theory.bean.aware;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.support.GenericApplicationContext;

/**
 * 阅读4-1
 * TestAware
 *
 * @author H
 * @version 1.0
 * @date 2023-12-27 13:58
 */
@Slf4j
public class TestAware {

    public static void main(String[] args) {
        GenericApplicationContext context = new GenericApplicationContext();
        context.registerBean(CommonAnnotationBeanPostProcessor.class);
        context.registerBean(AutowiredAnnotationBeanPostProcessor.class);
        context.registerBean(ConfigurationClassPostProcessor.class);

        /**
         * 内置功能（aware接口）和扩展功能（@AutoWired注解；扩展功能需要bean后处理器支持才能解析）对比
         */
        context.registerBean("awareBean", AwareBean.class);
        //注解失效演示
        //context.registerBean("awareConfig", AwareConfig.class);

        context.refresh();
        context.close();

    }

}
